{include file='comdir/head.html'}
<body>
<div class="content">
    <div class="animated fadeInDown">
        <div class="pos"><a href="#" onClick="javascript :history.back(-1);">返回上一页</a></div>
        <div class="btn-box">
            <button class="btn btn-sm btn-success siteadd">添加</button>
        </div>
        <div class="table_list_wrap">
            <div class="table-responsive">
                <table class="table table-bordered table-hover">
                    <thead>
                    <tr>
                        <th>站点logo</th>
                        <th>站点名称</th>
                        <th>站点访问文件名</th>
                        <th>站点域名</th>
                        <th>站点描述</th>
                        <th>主网站</th>
                        <th>状态</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody class="listtbody">
                    {foreach from=$list item=vo}
                    <tr class="siteid_{$vo.id}">
                        <td><img src="{$getConfig.upload_http}{$vo.logo}" style="max-width:100px;max-height:30px;"></td>
                        <td>{$vo.name}</td>
                        <td>{$vo.ename}</td>
                        <td>{$vo.domain}</td>
                        <td>{$vo.description}</td>
                        <td>{if $vo.ismain==1}是{else}否{/if}</td>
                        <td>{if $vo.status==1}开启{else}关闭{/if}</td>
                        <td>{$vo.addtime|date_format:'%Y-%m-%d %H:%M:%S'}</td>
                        <td>
                            <input type="button" onclick="column({$vo.id})" class="btn btn-xs btn-warning" value="栏目管理">
                            <input type="button" onclick="edit({$vo.id})" class="btn btn-xs btn-warning" value="编辑">
                            <input type="button" onclick="del({$vo.id})" class="btn btn-xs btn-danger" value="删除">
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
        
        <div class='tplselected' style="display:none">
            <select class="form-control ename">
                {foreach from=$enameMoudels key=key item=vm}
                <option value="{$key}">{$vm}</option>
                {/foreach}
            </select>
            <script type="text/javascript">
                $('.ename').change(function(){
                    value=$(this).val();
                    var option=$(this).find("option");
                    var len=option.length;
                    for(i=0;i<len;i++){
                        if(option[i].value==value){
                            $(".ename").find("option[value='"+value+"']").attr("selected",true);
                        }else{
                            $(".ename").find("option[value='"+option[i].value+"']").attr("selected",false);
                        }

                    }

                })
            </script>
        </div>
    </div>
    <div class="page-box">
        <div class="page">
            {if $list}
            {$pageshow}
            {/if}
        </div>
    </div>
</div>
</div>
<script type="text/javascript">
    var _URL='{$_URL}';
    var _getConfig='{$getConfig.upload_http}';
    {literal}
    $(function(){
        $('.siteadd').click(function(){
            window.location.href=_URL+"sites/add";
        })
    })
    function column(id){
        window.location.href=_URL+"Column/lists?sitesid="+id;
    }
    function edit(id){
        window.location.href=_URL+"sites/edit?id="+id;
    }
    function del(id){
        var url=_URL+"sites/del";
        var del_all=layer.confirm('确认要删除吗！', {btn: ['确认','取消'],'title':'站点'},function(){
            _ajaxs.post(url,'id='+id,function(data){
                if(data.status){
                    layer.msg(data.msg,{icon: 1}, function(){});
                    $('.siteid_'+id).remove();
                    layer.close(index);
                }else{
                    layer.msg(data.msg,{icon: 2}, function(){});
                }
                layer.close(index);
            })
        });
    }
    function tplselected(id,ename,dest){
        $(".ename").find("option[value='"+ename+"']").attr("selected",true);
        var str=$('.tplselected').html();
        layer.confirm(str,{title:'选择模版'},function(index){
            value=$('.ename').val();
            _ajaxs.post(_URL+"Sites/selMoudel",'id='+id+'&modoule='+value+'&ename='+dest, function(response){
                if(response.status == 1){
                    layer.msg(response.msg,{icon: 1}, function(){});
                }else{
                    layer.msg(response.msg,{icon: 2}, function(){});
                }
                layer.close(index);
            });
        });
    }
    function ajaxpage(page){
        url='';
        url+="page="+page;
        _ajaxs.post(_URL+"Sites/lists",url,function _return(data){
            $('.listtbody').html('');
            $('.listtbody').html(data.data.list);
            if(data.data.pageshow){
                $('.page').html(data.data.pageshow);
            }else{
                $('.page').html('');
            }
        },'json')
    }
    {/literal}
</script>

</body>
</html>